<!-- $Id: bonus_type_info.htm 14216 2008-03-10 02:27:21Z testyang $ -->
<script language="javascript" type="text/javascript" src="../js/DatePicker/WdatePicker.js"></script>
{include file="pageheader.htm"}
<div class="main-div">
<form action="bonus.php" method="post" name="theForm" enctype="multipart/form-data" onsubmit="return validate()">
<table width="100%">
  <tr>
    <td class="label">{$lang.type_name}</td>
    <td>
      <input type='text' name='type_name' maxlength="30" value="{$bonus_arr.type_name}" size='20' />    </td>
  </tr>
  <tr>
    <td class="label">选择商家</td>
    <td>   <select name="suppliers_id"  id="suppliers_id">

    	<option value="">请选择</option>
        <option value="0" {if $bonus_arr.suppliers_id eq '0'} selected="selected"{/if}>自营店</option>
        {foreach from=$suppliers_list item=suppliers}
        <option value="{$suppliers.suppliers_id}" {if $bonus_arr.suppliers_id eq $suppliers.suppliers_id} selected="selected"{/if}>{$suppliers.suppliers_name}</option>
        {/foreach}
    </select></td>
  </tr>
  <tr>
    <td class="label">
      <a href="javascript:showNotice('Type_money_a');" title="{$lang.form_notice}">
      <img src="images/notice.gif" width="16" height="16" border="0" alt="{$lang.form_notice}"></a>{$lang.type_money}</td>
    <td>
    <input type="text" name="type_money" value="{$bonus_arr.type_money}" size="20" />
    <br /><span class="notice-span" {if $help_open}style="display:block" {else} style="display:none" {/if} id="Type_money_a">{$lang.type_money_notic}</span>    </td>
  </tr>
  <tr>
    <td class="label"><a href="javascript:showNotice('NoticeMinGoodsAmount');" title="{$lang.form_notice}"> <img src="images/notice.gif" width="16" height="16" border="0" alt="{$lang.form_notice}" /></a>{$lang.min_goods_amount}</td>
    <td><input name="min_goods_amount" type="text" id="min_goods_amount" value="{$bonus_arr.min_goods_amount}" size="20" />
    <br /><span class="notice-span" {if $help_open}style="display:block" {else} style="display:none" {/if} id="NoticeMinGoodsAmount">{$lang.notice_min_goods_amount}</span> </td>
  </tr>
  <tr>
    <td class="label">{$lang.send_method}</td>
    <td>
      <input type="radio" name="send_type" value="0" {if $bonus_arr.send_type eq 0} checked="true" {/if} onClick="showunit(0)"  />{$lang.send_by[0]}
      <input type="radio" name="send_type" value="1" {if $bonus_arr.send_type eq 1} checked="true" {/if} onClick="showunit(1)"  />{$lang.send_by[1]}
      <input type="radio" name="send_type" value="2" {if $bonus_arr.send_type eq 2} checked="true" {/if} onClick="showunit(2)"  />{$lang.send_by[2]}
      <input type="radio" name="send_type" value="3" {if $bonus_arr.send_type eq 3} checked="true" {/if} onClick="showunit(3)"  />{$lang.send_by[3]}    </td>
  </tr>
  <tr>
    <td class="label"><a href="javascript:showNotice('NoticeIsShare');" title="{$lang.form_notice}"> <img src="images/notice.gif" width="16" height="16" border="0" alt="{$lang.form_notice}" /></a>{$lang.is_share}</td>
    <td>
      <input type="radio" name="is_share" value="0" {if $bonus_arr.is_share neq 1} checked="true" {/if} onclick="document.getElementById('number_tr').style.display='none';"  />{$lang.share_by[0]}
      <input type="radio" name="is_share" value="1" {if $bonus_arr.is_share eq 1} checked="true" {/if}  onclick="document.getElementById('number_tr').style.display='';"  />{$lang.share_by[1]}
      <br /><span class="notice-span" {if $help_open}style="display:block" {else} style="display:none" {/if} id="NoticeIsShare">设置为好友券必须分享给好友使用</span> 
    </td>
  </tr>
  <!-- 
  <tr id="amount_tr" {if $bonus_arr.is_share neq 1} style="display:none" {/if} >
    <td class="label">发放优惠券的总金额</td>
    <td>
    	<input type="text" value="" name="amount" >
    </td>
  </tr>
   -->
  <tr id="number_tr" {if $bonus_arr.is_share neq 1} style="display:none" {/if}>
    <td class="label">发放优惠券的数量</td>
    <td>
    	<input type="text" value="{$bonus_arr.number}" name="number"  >
    </td>
  </tr>

  <tr id="type_3" {if $bonus_arr.is_online neq 1} style="display:none" {/if}>
    <td class="label">参与线上领取：</td>
    <td>
      <input type="checkbox" value="1" name="is_online" {if $bonus_arr.is_online eq 1} checked{/if} >
    </td>
  </tr>
  <tr>
    <td class="label">是否全站通用</td>
    <td>
      <input type="radio" name="tongyong" value="0" {if $bonus_arr.tongyong neq 1} checked="true" {/if}   />否
      <input type="radio" name="tongyong" value="1" {if $bonus_arr.tongyong eq 1} checked="true" {/if}   />是
    </td>
  </tr> 
  <tr>
    <td class="label">是否仅限团长使用</td>
    <td>
      <input type="radio" name="only_first" value="0" {if $bonus_arr.only_first neq 1} checked="true" {/if}   />否
      <input type="radio" name="only_first" value="1" {if $bonus_arr.only_first eq 1} checked="true" {/if}   />是
    </td>
  </tr>  
  <tr>
    <td class="label">是否免单券</td>
    <td>
      <input type="radio" name="free_all" value="0" {if $bonus_arr.free_all neq 1} checked="true" {/if}   />否
      <input type="radio" name="free_all" value="1" {if $bonus_arr.free_all eq 1} checked="true" {/if}   />是
      <br /><span>请在商品详情设置使用，发放商品只能选择一个商品</span> 
    </td>
  </tr>
  <tr id="1" style="display:none">
    <td class="label">
      <a href="javascript:showNotice('Order_money_a');" title="{$lang.form_notice}">
      <img src="images/notice.gif" width="16" height="16" border="0" alt="{$lang.form_notice}"></a>{$lang.min_amount}</td>
    <td>
      <input name="min_amount" type="text" id="min_amount" value="{$bonus_arr.min_amount}" size="20" />
      <br /><span class="notice-span" {if $help_open}style="display:block" {else} style="display:none" {/if} id="Order_money_a">{$lang.order_money_notic}</span>    </td>
  </tr>
  <tr>
    <td class="label">
      <a href="javascript:showNotice('Send_start_a');" title="{$lang.form_notice}">
      <img src="images/notice.gif" width="16" height="16" border="0" alt="{$lang.form_notice}"></a>{$lang.send_startdate}</td>
    <td>
      <input class="Wdate" name="send_start_date" type="text" size="22" value='{$bonus_arr.send_start_date}' readonly="readonly" onfocus="WdatePicker()"/>
      <br /><span class="notice-span" {if $help_open}style="display:block" {else} style="display:none" {/if} id="Send_start_a">{$lang.send_startdate_notic}</span>    </td>
  </tr>
  <tr>
    <td class="label">{$lang.send_enddate}</td>
    <td>
      <input class="Wdate" name="send_end_date" type="text" size="22" value='{$bonus_arr.send_end_date}' readonly="readonly" onfocus="WdatePicker({minDate:'%y-%M-%d'})"/></td>
  </tr>
  <tr>
    <td class="label">
	  <a href="javascript:showNotice('Use_start_a');" title="{$lang.form_notice}">
      <img src="images/notice.gif" width="16" height="16" border="0" alt="{$lang.form_notice}"></a>
	{$lang.use_startdate}</td>
    <td>
      <input class="Wdate" name="use_start_date" type="text" size="22" value='{$bonus_arr.use_start_date}' readonly="readonly" onfocus="WdatePicker({minDate:'%y-%M-%d'})"/>
	  <br /><span class="notice-span" {if $help_open}style="display:block" {else} style="display:none" {/if} id="Use_start_a">{$lang.use_startdate_notic}</span></td>
  </tr>
  <tr>
    <td class="label">{$lang.use_enddate}</td>
    <td>
      <input class="Wdate" name="use_end_date" type="text" size="22" value='{$bonus_arr.use_end_date}' readonly="readonly" onfocus="WdatePicker({minDate:'%y-%M-%d'})"/></td>
  </tr>
  <tr>
    <td class="label">&nbsp;</td>
    <td>
      <input type="submit" value="{$lang.button_submit}" class="button" />
      <input type="reset" value="{$lang.button_reset}" class="button" />
      <input type="hidden" name="act" value="{$form_act}" />
      <input type="hidden" name="type_id" value="{$bonus_arr.type_id}" />    </td>
  </tr>
</table>
</form>
</div>
{insert_scripts files="../js/utils.js,validator.js"}
{literal}
<script language="javascript">
<!--
document.forms['theForm'].elements['type_name'].focus();
/**
 * 检查表单输入的数据
 */
function validate()
{
  validator = new Validator("theForm");
  
  validator.required("type_name",      type_name_empty);
  validator.required("type_money",     type_money_empty);
  if(document.forms['theForm'].elements['is_share'].value==1){
	  validator.isInt("type_money",  "优惠券金额必须是整数", true);
	  if(document.forms['theForm'].elements['type_money'].value<=0){
		  validator.addErrorMsg('优惠券金额必须大于0');
	  }
  }else{
	  validator.isNumber("type_money",     type_money_isnumber, true);
  }
  
  if(document.forms['theForm'].elements['is_share'].value==1){
	  validator.required("number",     "优惠券发放数量不能为空");
	  validator.isNumber("number",  "优惠券发放数量必须是数值", true);
  }
 
  validator.islt('send_start_date', 'send_end_date', send_start_lt_end);
  validator.islt('use_start_date', 'use_end_date', use_start_lt_end);
  if (document.getElementById(1).style.display == "")
  {
    var minAmount = parseFloat(document.forms['theForm'].elements['min_amount'].value);
    if (isNaN(minAmount) || minAmount <= 0)
    {
	  validator.addErrorMsg(invalid_min_amount);
    }	
  }
  
  return validator.passed();
}
onload = function()
{
  {/literal}
  get_value = '{$bonus_arr.send_type}';
  {literal}

  showunit(get_value)
  // 开始检查订单
  startCheckOrder();
}
/* 优惠劵类型按订单金额发放时才填写 */
function gObj(obj)
{
  var theObj;
  if (document.getElementById)
  {
    if (typeof obj=="string") {
      return document.getElementById(obj);
    } else {
      return obj.style;
    }
  }
  return null;
}

function showunit(get_value)
{
  gObj("1").style.display =  (get_value == 2) ? "" : "none";
  gObj("type_3").style.display =  (get_value == 3) ? "" : "none";
  document.forms['theForm'].elements['selbtn1'].disabled  = (get_value != 1 && get_value != 2);
  document.forms['theForm'].elements['selbtn2'].disabled  = (get_value != 1 && get_value != 2);

  return;
}
//-->
</script>
{/literal}
{include file="pagefooter.htm"}
